/*
 * main.cpp
 *
 *  Created on: 2016-7-10
 *      Author: sadne
 */

#include "./BFX/Socket.h"
#include "./BFX/Selector.h"
#include "./BFX/DateTime.h"

#include <stdio.h>

#include "BFX/AcceptSocketChannel.h"

#include <errno.h>

using namespace BFX;

REF<Selector> __selector = nullptr;

int main(int argc, char* argv[]) {
#ifdef __CYGWIN__
	setbuf(stdout, NULL);
#endif

	__selector = new DefaultSelector();

	REF<InetAddress> addr = new InetAddress(2593);
	REF<AcceptSocketChannel> acceptor = new AcceptSocketChannel(addr);
	acceptor->registerKey(__selector, SelectionKey::OP_ACCEPT, nullptr);

	for (;;) {
		int n = __selector->select(1000);
		(void) n;
	}

	acceptor->stop();
	__selector = nullptr;

	return 0;
}

